<template>
	<div>
		 <bbsInfoDetail :bbsInfo="bbsInfos" :userInfo="userInfos"></bbsInfoDetail>
		<el-table :data="bbsInfo" height="700" border style="width: 100%;">
			<el-table-column prop="uid" label="用户id" width="150">
			</el-table-column>
			
			<el-table-column prop="bbsstage" label="留言状态" width="150">
			</el-table-column>
			<el-table-column prop="bbstime" label="留言时间">
			</el-table-column>
			<el-table-column label="操作" width="250" fixed="right">
				<template slot-scope="scope">
					<el-button @click="handleClick(scope.row)" type="text" size="small" icon="el-icon-document">详情</el-button>
					<!-- <el-button @click="handleClick(scope.row)" type="text" size="small">删除</el-button> -->
				</template>
			</el-table-column>
		</el-table>
		<!-- <mealInfoadd></mealInfoadd> -->
	<!-- 	<bbsInfoDetail :bbsInfo="bbsInfos"></bbsInfoDetail> -->
	</div>
</template>
<script>
	// import mealInfoDetail from '@/components/meal_info/Meal_info_detail.vue'
	// import mealInfoadd from '@/components/meal_info/Meal_info_add.vue'
	import bbsInfoDetail from '@/components/bbs_info/Bbs_info_detail.vue'
	import {
		request
	} from "network/request.js"

	export default {
		components: {

			bbsInfoDetail
		},
		data() {
			return {
				userInfos:'',
				bbsInfos:'',
				bbsInfo: [
					 {
					    "bbsid": 0,
					    "bbsremark": "信息暂无",
					    "bbsstage": "信息暂无",
					    "bbstime": "信息暂无",
					    "bbstype": "信息暂无",
					    "uid": 0
					  }
				]
			}
		},
		methods: {
			handleClick(row) {
				//console.log(row.mealid)
				 
				// this.$store.commit("updateMealid", row.mealid)
				request({
					url: '/BbsInfo/BbsinfoByBbsid',
					method: 'get',
					params:{
						// id:this.$store.state.mealid
						bbsid:row.bbsid
					}
				}).then(res=>{
					 // console.log(row.bbsid)
					 // console.log(res.data)	

					if(res.data.bbsstage=='1'){
						res.data.bbsstage=true
					}else {
						res.data.bbsstage=false
					}
					this.bbsInfos=res.data
					// console.log(this.mealInfos)
				})
				//查询发送此条信息的用户信息
				request({
					url: '/User/UserInfo',
					method: 'get',
					params:{
						// id:this.$store.state.mealid
						uid:row.uid
					}
				}).then(res=>{
					// console.log(res.data)
					this.userInfos=res.data
				})
				this.$store.commit("updateBbsInfoflag", true)
			}

		},
		created() {
			request({
				url: '/BbsInfo/BbsinfoAll',
				method: 'get'
			}).then(res => {
					// console.log(res.data)	
				res.data=res.data.filter(item => item.bbsstage!='2' )
				// console.log(res.data)	
				if (res.data.length > 0) {
					res.data.forEach(s => {
						if(s.bbsstage=="0"){
							s.bbsstage="未查看"
						}else{
							s.bbsstage="已查看"
						}
					})
					 this.bbsInfo = res.data
					// console.log(this.bbsInfo)
				}
			})
		}

	}
</script>
<style scoped>
	el-table-column {
		height: 50px;
	}

	.el-main {
		line-height: 20px;
	}
</style>
